<?php
const UPLOAD_DIR = 'http://192.168.119.59/pattern/backend/api/';
// const UPLOAD_DIR = 'http://192.168.0.75/pattern/backend/api/';

function curl_post($url,$post_data)
{
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    $output = curl_exec($ch);
    curl_close($ch);
    return  $output;
}

function imageSearch($path) {

//        $post_data = [
//            'file' => new \CURLFile(UPLOAD_DIR . $path),  //必须是绝对路径
//        ];
    $post_data = [
        'file' => '@' . UPLOAD_DIR . $path,  //必须是绝对路径
    ];

    $rt = curl_post('http://127.0.0.1:5001/uploader', $post_data);

    print_r($rt);

    return $rt;
}

imageSearch();
